<div id="main">
    <div id="contents">
        <form method="post" action="#" name="filters">
            <fieldset>
                <legend>
                    <label sid="ports.basic_setting"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="id2264">
                                    <label sid="wireless_basic.macfiltering"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">

                                <input id="id2264_2" type="radio" value="1" name="id2264">
                                <label sid="main.enable"></label>
                                <span style="padding-left:10px;"></span>
                                <input id="id2264_1" type="radio" checked="" value="0" name="id2264">
                                <label sid="main.disable"></label>

                            </td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">&nbsp;</td>
                            <td class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="id2264">
                                    <label sid="wireless_basic.macfiltering2"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2264_3" type="radio" checked="" value="1" name="id2264_radio">
                                <label sid="wireless_basic.allow"></label>
                                <br>
                                <br>
                                <input id="id2264_4" type="radio" value="2" name="id2264_radio">
                               <label sid="wireless_basic.reject"></label>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input class="button" type="button" name="submit" sid="sbutton.save">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="wireless_basic.addmac"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="comment">
                                    <label sid="wrom_status.mac "></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="mac" type="text" maxlength="32" size="18" name="mac">
                                <span class="x-form-tip" id="macTip"></span>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input id="save_button" class="button" type="button"  name="save_button" sid="sbutton.add">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="wireless_basic.maclist"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table id="mactable" class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%"> </table>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<br>
<div id="helpContainer">
    <div id="help">
        <div>
            <h2>
                <label sid="share.help"></label>
            </h2>
        </div>
        <div id="helpBody">
        <dl>
            <dt class="term">
                <label sid="wireless_basic.macfiltering"></label>
            </dt>
            <dd class="definition">
                <label sid="wireless_basic.macfiltering_note"></label>
            </dd>
            <dt class="term">
                <label sid="wireless_basic.addmac"></label>
            </dt>
            <dd class="definition">
                <label sid="ports.comment2"></label>
            </dd>
        </dl>
       </div>
    </div>
</div>


<script type="text/javascript" src="js/libTable.js"></script>
<script type="text/javascript">
        var virtual_data = new Array();
        var old_virtual=0;
        load_html();
        $.formValidator.initConfig({debug:false,submitOnce:true,submitButtonID:"save_button",
            onError:function(msg, obj, errorlist) {

            },
            onSuccess:function(){
                var mac = $("#mac").val();
                if($("#save_button").val()==sbutton.modify){
                    virtual_data[old_virtual] = mac;
                }else{
                    virtual_data[virtual_data.length]=mac;
                }

                if(virtual_data.length > 20)
                {
                    //show_message("err",dialingRules.limit);
                    alert(dialingRules.limit);
                }else{
                    var resultStr = '';
                    for(var i=0;i<virtual_data.length;i++){
                        resultStr += virtual_data[i]+";";
                    }
                    resultStr = resultStr.substr(0,resultStr.length-1);
                    var settext='&id2265='+resultStr;
                    submitform(modules["set_data"],settext,"mac_filtering_main_load");
                    load_html();
                }
            }
        });
        $("#mac").formValidator({
            onFocus:errmsg.Info7
        }).regexValidator({
                    regExp:regexEnum.notempty,
                    onError:errmsg.Info3
                }).regexValidator({
                    regExp:regexEnum.mac,
                    onError:errmsg.Info1
                });

        $("[name=submit]").click(function () {
            $(".errormsg").html('');
            var settext = "";
            if($("#id2264_1").attr("checked")){
                settext +="&id2264=0";
            }else if($("#id2264_3").attr("checked")){
                settext +="&id2264=1";
            }else if($("#id2264_4").attr("checked")){
                settext +="&id2264=2";
            }
            submitform(modules["set_data"],settext,"mac_filtering_main_load");

        });


	
function load_html(){
	var sendtext = '&id=2264&id=2265';
	DataRequest("get_json",sendtext,function(data){
		var value2264 = data["id2264"];
		if(value2264 == "0"){
			$("#id2264_1").attr("checked",true);
			}else if(value2264 == "1"){
				$("#id2264_2").attr("checked",true);
				$("#id2264_3").attr("checked",true);
			}else if(value2264 == "2"){
				$("#id2264_2").attr("checked",true);
				$("#id2264_4").attr("checked",true);
			}
		var tmparray = strToJSON(data["id2265"]);
		if(tmparray!=""&&tmparray){
		virtual_data = tmparray;
		virtual_paint_list(tmparray);
		}
	});
}

function virtual_paint_list(data){
 var data_new=new Array();
 var j=0;
  for(var i=0;i<data.length;i++){
 	var ID = parseInt(parseInt(i)+1);
  	var mac = replacestr(data[i]);
  	
  data_new.push({ID:ID,mac:mac});
  j = i;
 }
 var fun_arr = [{type:"modify",name:"virtual_change"},{type:"del",name:"virtual_del"}];
 var tab = new libTable(new Array(content.filter_webs_url_fitler_No,wrom_status.mac,msg.op),data_new,1,10);
 print_table("mactable",tab,fun_arr, true);
}

function virtual_change(id,mac)
{
  obj = virtual_data[parseInt(id)-1];
 old_virtual = parseInt(id)-1;
 with(obj){
  $("#mac").val(mac);
 }
 $("#save_button").val(sbutton.modify);
}


function virtual_del(id,mac){
  if(confirm(msg.confirm_del)){
 //show_message("del",msg.deleting);
 virtual_data[parseInt(id)-1] = [];
 var resultStr = '';
  for(var i=0;i<virtual_data.length;i++){
  	if(virtual_data[i]&&virtual_data[i]!=""){
  		resultStr += virtual_data[i]+";";
 	 }
  	}
  	resultStr = resultStr.substr(0,resultStr.length-1);
  var settext='&id2265='+resultStr;
  submitform(modules["set_data"],settext,"mac_filtering_main_load");
  load_html();
 }
}
</script>
